<?php
	
	if(isset($_SESSION['id'])):
		$id = checkSession();
		$query3 = "SELECT * FROM `friendrequests_table` WHERE `receiverId` = $id";
		$friendsr = mysql_query($query3);
		$numfriendsr = mysql_num_rows($friendsr);
			
			if ($numfriendsr >=1):
				for($i = 1; $i<=$numfriendsr; $i++ ){
					$friendr = mysql_fetch_array($friendsr);
					$query4 = "SELECT * from `user_table` WHERE `userId` = ".$friendr['senderId'];	
					$users1 = mysql_query($query4);
					$user1 = mysql_fetch_array($users1);
				} 
			endif;	
	endif;
?>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>MFI Foundation Inc.</title>
		<link type="text/css" href="css/custom-theme/jquery-ui-1.8.18.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/chat.js"></script>
		
		<link rel="stylesheet" href="css/style.css"  type="text/css" media="screen" />
		<link rel="stylesheet" href="css/portal.css"  type="text/css" media="screen" />
		
		<link type="text/css" rel="stylesheet" media="all" href="css/chat.css" />
		<link type="text/css" rel="stylesheet" media="all" href="css/screen.css" />
	
		
		<?php if(!isset($_SESSION['id']))  include 'popup.php';  ?>
	</head>
	<body>
		<div id="wrapper">
			<div id="head" style = "background-image : url('image/banner2.jpg');"></div>
			<div style="clear:both;"></div>
				<div id = 'menu1' class = "navigation">
					<ul>
						<li style="margin-left: 15px;"><a href="home.php">Home</a></li>
						<?php if(isset($_SESSION['id'])): ?>
						<li><a href="profile.php">Profile</a></li>
						<li><a href = "#">Friend Requests(<?php echo $numfriendsr; ?>)</a>
						<?php
							$id = checkSession();
							if ($numfriendsr >=1){
								echo "<ul>";
								for($i = 1; $i<=$numfriendsr; $i++ ){
									$friendr = mysql_fetch_array($friendsr);
									$query4 = "Select * from user_table where userId = ".$friendr['senderId'];	
									$users1 = mysql_query($query4);
									$user1 = mysql_fetch_array($users1);
									echo "<li><form method=\"POST\" action = \"acceptReject.php?id=".$friendr['senderId']."&uid=$id\">". $user1['firstName'] . " " . $user1['lastName']." wants to be your friend
										 <input type = \"hidden\" value = \"home\" name = \"location\"/>
										 <input type = \"submit\" value = \"Confirm\" name = \"ac\"/>
										 <input type = \"submit\" value = \"Reject\" name = \"ac\"/>
										  
										  </form></li>";
								} 
								echo "</ul>";
							}
						?>	
						<li style="padding-left: 475px;">
							<form action="searchUser.php" method="POST">
								<input type="text" name="search"/> 
								<input type="submit" value="Search" />
							</form>
						</li>
						<li style="margin-right: 10px;"><a href="logout.php">Logout</a></li>
						<?php else: ?>
							<li style="padding-left: 600px;">
								<form action="searchUser.php" method="POST">
									<input type="text" name="search"/> 
									<input type="submit" value="Search" />
								</form>
							</li>
						<li style="margin-right: 10px;"><a id="signup">Sign Up</a></li>
						<li style="margin-right: 10px;"><a id="login">Login</a></li>
						<?php endif; ?>
					</ul>	
				</div>